import React from 'react';
import {BrowserRouter as Router, Route, Switch } from 'react-router-dom';
import Loading from '../components/loading';
import App from '@/pages/index';
// 按路由拆分代码
import Loadable from 'react-loadable';

const getComponent = (page) => Loadable({
    loader: () => import(`../pages/${page}`),
    loading: Loading,
    timeout: 10000,
});

export const RouterConfig = () => (
    <Router>
        <App>
            <Switch>
                <Route exact path="/" component={getComponent('demo')} />
                <Route exact path="/amap" component={getComponent('amap')} />
            </Switch>
        </App>
    </Router>
);
